% compZWK4.m
% calculates input impedance of 4-element windkessel model

clear Zmod;

freq=(0:1:npoints-1)/T;
omega=2*pi*freq;
Ztheor=(R./(1+i*omega*R*C))+(i*omega*L*Z0)./(Z0+i*omega*L);

% put computed input impedance in the right format to allow the inverse fourier transform

Zmod(1)=Ztheor(1);	% first harmonic

% for the other harmonics, it depends whether the number of points is odd or even

if (npoints-round(npoints/2)*2)==0					% npoints is even
   for k=2:npoints/2
      Zmod(k)=Ztheor(k);
      Zmod(npoints+2-k)=conj(Zmod(k));
   end;
      Zmod(npoints/2+1)=Ztheor(npoints/2+1);
else														% npoints is odd
   for k=2:(npoints+1)/2
      Zmod(k)=Ztheor(k);
      Zmod(npoints+2-k)=conj(Zmod(k));
   end;
end;     

     
     
